

<ul id="nav">
	<li class="top">
		<a href="index.php?co=pageStructure" class="top_link"><span>Seitenstruktur verwalten</span></a>
		
	</li>
	<li class="top">
		<a href="index.php?co=newPage" class="top_link"><span class="down">Neue Seite unterhalb</span></a>
		<?php showPages($this->aDisplayedContent['contentANDproductPages'], $sUlID = 'class="sub"', $iCompLevel = 0)?>
	</li>
	<li class="top">
		<a href="" class="top_link"><span class="down">Neue Produktkategorie unter</span></a>
		<ul class="sub">
		<?php $aProducts = $this->aDisplayedContent['products'];
		if (is_array($aProducts)&&!empty($aProducts)){
		    foreach($aProducts as $aProduct){
		        $iProductPageID = $aProduct['id'];
		        $sProductPageName = $aProduct['name'];
		        echo "<li><a href=index.php?co=newPage&type=category&ppid=$iProductPageID>$sProductPageName</a></li>";
		    }
		}
		?>
		</ul>
	</li>
	<li class="top">
		<a href="" class="top_link"><span class="down">Neues Produkt in</span></a>
		<ul class="sub">
		<?php $aCategories = $this->aDisplayedContent['categories'];
		if (is_array($aCategories)&&!empty($aCategories)){
		    foreach($aCategories as $aCategory){
		        $iCategoryPageID = $aCategory['id'];
		        $sCategoryPageName = $aCategory['name'];
		        echo "<li><a href=index.php?co=newProduct&addNewProduct&ca=$iCategoryPageID>$sCategoryPageName</a></li>";
		    }
		}
		?>
		</ul>
	</li>
	<li class="top">
		<a href="index.php?co=userMgmt" class="top_link"><span>Einstellungen</span></a>
	</li>
</ul>

<?php function showPages($aPageStructureNested, $sUlID = "", $iCompLevel = ''){
    if ($iCompLevel == ""){
        $iCompLevel = 0;
    }
    echo "<ul $sUlID>";
    foreach ($aPageStructureNested as $aPage){
                
        $sUlClass = '';
        $sLiClass = "";
        $sAClass = '';
        $sBeginSpan = '';
        $sEndSpan = '';
        
        $iPageID = $aPage['id'];
        $sPageName = $aPage['name'];
        $iPageLevel = $aPage['level'];
        $sPageLink = "index.php?co=newPage&parentID=$iPageID";
        
        if($iPageLevel == $iCompLevel && !empty($aPage['subPages'])){$sUlClass = "class=sub";}
        if($iPageLevel == $iCompLevel){$sLiClass="class=top";}
        if(!empty($aPage['subPages']) && $iPageLevel == $iCompLevel+1){$sLiClass="class=mid";}
        if($iPageLevel == $iCompLevel){$sAClass="class=top_link";}
        if(!empty($aPage['subPages']) && $iPageLevel == $iCompLevel+1){$sAClass="class=fly";}
        if($iPageLevel == $iCompLevel || $iPageLevel == $iCompLevel+1){$sEndSpan= "</span>";}
        if(empty($aPage['subPages'])){$sBeginSpan = "<span>";}
        if(!empty($aPage['subPages']) && $iPageLevel == $iCompLevel){$sBeginSpan = "<span class=\"down\">";}
        
        
        echo "<li $sLiClass><a href='$sPageLink' $sAClass>$sBeginSpan $sPageName $sEndSpan</a>";
        if(!empty($aPage['subPages'])){
            showPages($aPage['subPages'], $sUlClass);
     }?></li><?php 
    }
    echo "</ul>";
  }?>



